feat: add custom protoc-gen-zod plugin with buf.validate support#31
Merged
Conversation
Add a custom Buf plugin that generates Zod schemas from proto definitions with automatic validation rules from buf.validate annotations. Features: - Converts buf.validate constraints to Zod validations (.min(), .startsWith(), etc.) - Generates enum helper maps (ENUM_MAP and STRING_TO_ENUM) - Supports all scalar types, well-known types, and wrapper types - Handles recursive message types with z.lazy() - Skips empty files (no messages/enums) - Uses z.enum() instead of deprecated z.nativeEnum() for Zod v4 New files: - tools/zod/ - Custom protoc-gen-zod plugin source - .npmrc - Buf registry config for @buf/* dependencies fix: change module type from ESNext to CommonJS in package.json and tsconfig.gen.json feat(validation): enhance item-level constraints for repeated fields in Zod schemas feat(validation): add support for int64/uint64 constraints in Zod validation chains feat(validation): update file_id validation to use pattern matching for file identifiers feat(validation): enhance validation handling for optional fields and string patterns in Zod schemas fix(filesystem): regex in fileFilter prefix fix(filesystem): allow 'default' as valid context in UploadFileData Update the context field validation pattern to accept 'default' as a valid value in addition to the existing missions: and setups: prefixes. chore: update devDependencies in package.json - Bump @bufbuild/buf from 1.61.0 to 1.64.0 - Update @types/node from 25.0.3 to 25.2.0 fix(filesystem): enhance regex for prefix validation in FileFilter and UploadFileData Updated the regex pattern for the 'prefix' field in FileFilter to prevent path traversal and ensure valid path formats. Additionally, added a pattern validation for the 'name' field in UploadFileData to enforce similar constraints. fix(dependencies): update grpc-js, zod, and bufbuild packages to latest versions
Relixik
approved these changes
Feb 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add a custom Buf plugin that generates Zod schemas from proto definitions with automatic validation rules from buf.validate annotations.
Features:
New files:
fix: change module type from ESNext to CommonJS in package.json and tsconfig.gen.json
feat(validation): enhance item-level constraints for repeated fields in Zod schemas
feat(validation): add support for int64/uint64 constraints in Zod validation chains
feat(validation): update file_id validation to use pattern matching for file identifiers
feat(validation): enhance validation handling for optional fields and string patterns in Zod schemas
fix(filesystem): regex in fileFilter prefix
fix(filesystem): allow 'default' as valid context in UploadFileData
Update the context field validation pattern to accept 'default' as a valid value in addition to the existing missions: and setups: prefixes.
chore: update devDependencies in package.json
fix(filesystem): enhance regex for prefix validation in FileFilter and UploadFileData
Updated the regex pattern for the 'prefix' field in FileFilter to prevent path traversal and ensure valid path formats. Additionally, added a pattern validation for the 'name' field in UploadFileData to enforce similar constraints.
fix(dependencies): update grpc-js, zod, and bufbuild packages to latest versions